window.onload = function () {




    let jobsjson = {
        'job': '前端开发工程师[苏州]',
        'money': '12k~18k',
        'school': '本科',
        'condition': '应届生',
        'leftimg': 'msgImg.png',
        'boss': '李未经理',
        'jobSpan1': '前端高级开发',
        'jobSpan2': 'hhhhh',
        'jobSpan3': 'html+css',
        'company': '驰星教育',
        'comImg': 'tat.jpg',
        'comSpan1': '互联网',
        'comSpan2': '已上市',
        'comSpan3': '1000人以上',
        'commsg': '定期体检，带薪年假，节日福利'
    }

    $.get('/dev/post/postmsg?pageNum=1', function (result) {
        console.log(result)
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left_top");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney=""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples=""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            let pageInfo = result.data.jobPageInfo;
            let startPage = pageInfo.pageNum;
            if (startPage + 2 >= pageInfo.pages) {
                startPage = pageInfo.pages - 2
            }
            let ulPage = `<div style="margin-top: 55px">
                        <ul class="pagination">`;

            if (startPage <= 1) {
                ulPage += `<li class="disabled"><a href="javascript:void(0)">«</a></li>`;
            } else {
                ulPage += `<li><a href="javascript:page(${pageInfo.pageNum - 1})">«</a></li>`
            }

            for (var k = startPage; k <= startPage + 2; k++) {
                ulPage += `<li><a `;
                if (pageInfo.pageNum == k) {
                    ulPage += ` class="active href="javascript:page(${k})">${k}</a></li>`;
                } else {
                    ulPage += ` href="javascript:page(${k})">${k}</a></li>`;
                }
            }

            if (pageInfo.pageNum >= pageInfo.pages) {
                ulPage += ` <li class="disabled"><a href="javascript:void(0)">»</a></li>`;
            } else {
                ulPage += ` <li><a href="javascript:page(${pageInfo.pageNum + 1})">»</a></li>`;
            }
            ulPage += ` <li ><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>`;
            ulPage += ` </ul>
                    </div>`;

            strjobs += ulPage;
            jobs.innerHTML = strjobs;
        }


    })



}

function goPersonal(){
    window.location.replace("http://localhost:8088/dev/personal/p")
}

function page(n) {
    $.get('/dev/post/postmsg?pageNum='+n, function (result) {
        console.log(result)
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left_top");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney=""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples=""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            let pageInfo = result.data.jobPageInfo;
            let startPage = pageInfo.pageNum;
            if (startPage + 2 >= pageInfo.pages) {
                startPage = pageInfo.pages - 2
            }
            let ulPage = `<div style="margin-top: 55px">
                        <ul class="pagination">`;

            if (startPage <= 1) {
                ulPage += `<li class="disabled"><a href="javascript:void(0)">«</a></li>`;
            } else {
                ulPage += `<li><a href="javascript:page(${pageInfo.pageNum - 1})">«</a></li>`
            }

            for (var k = startPage; k <= startPage + 2; k++) {
                ulPage += `<li><a `;
                if (pageInfo.pageNum == k) {
                    ulPage += ` class="active href="javascript:page(${k})">${k}</a></li>`;
                } else {
                    ulPage += ` href="javascript:page(${k})">${k}</a></li>`;
                }
            }

            if (pageInfo.pageNum >= pageInfo.pages) {
                ulPage += ` <li class="disabled"><a href="javascript:void(0)">»</a></li>`;
            } else {
                ulPage += ` <li><a href="javascript:page(${pageInfo.pageNum + 1})">»</a></li>`;
            }
            ulPage += ` <li ><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>`;
            ulPage += ` </ul>
                    </div>`;

            strjobs += ulPage;
            jobs.innerHTML = strjobs;
        }


    })
}

function searchCity(e){
    let city=$(e).text();
    $.get('/dev/post/postcitysearch?pageNum=1&city='+city, function (result) {
        console.log(result)
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left_top");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney=""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples=""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            let pageInfo = result.data.jobPageInfo;
            let startPage = pageInfo.pageNum;
            if (startPage + 2 >= pageInfo.pages) {
                startPage = pageInfo.pages - 2
            }
            let ulPage = `<div style="margin-top: 55px">
                        <ul class="pagination">`;

            if (startPage <= 1) {
                ulPage += `<li class="disabled"><a href="javascript:void(0)">«</a></li>`;
            } else {
                ulPage += `<li><a href="javascript:page(${pageInfo.pageNum - 1})">«</a></li>`
            }
            if(startPage<=0){
                startPage=1
            }
            let endPage=0;
            if (startPage+2>pageInfo.pages){
                endPage=pageInfo.pages
            }else {
                endPage=startPage+2;
            }

            for (var k = startPage; k <=endPage; k++) {
                ulPage += `<li><a `;
                if (pageInfo.pageNum == k) {
                    ulPage += ` class="active href="javascript:page(${k})">${k}</a></li>`;
                } else {
                    ulPage += ` href="javascript:page(${k})">${k}</a></li>`;
                }
            }

            if (pageInfo.pageNum >= pageInfo.pages) {
                ulPage += ` <li class="disabled"><a href="javascript:void(0)">»</a></li>`;
            } else {
                ulPage += ` <li><a href="javascript:page(${pageInfo.pageNum + 1})">»</a></li>`;
            }
            ulPage += ` <li ><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>`;
            ulPage += ` </ul>
                    </div>`;

            strjobs += ulPage;
            jobs.innerHTML = strjobs;
        }


    })
}


function searchSchool(e){
    let shcoolLevel=null;
    switch ($(e).text()){
        case "大专以下":
            shcoolLevel=0
            break;
        case "大专":
            shcoolLevel=1
            break;
        case "本科":
            shcoolLevel=2
            break;
        case "硕士":
            shcoolLevel=3
            break;
        case "博士":
            shcoolLevel=4
            break;
    }

    $.get('/dev/post/postschoolsearch?pageNum=1&school='+shcoolLevel, function (result) {
        console.log(result)
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left_top");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney=""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples=""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            let pageInfo = result.data.jobPageInfo;
            let startPage = pageInfo.pageNum;
            if (startPage + 2 >= pageInfo.pages) {
                startPage = pageInfo.pages - 2
            }
            let ulPage = `<div style="margin-top: 55px">
                        <ul class="pagination">`;

            if (startPage <= 1) {
                ulPage += `<li class="disabled"><a href="javascript:void(0)">«</a></li>`;
            } else {
                ulPage += `<li><a href="javascript:page(${pageInfo.pageNum - 1})">«</a></li>`
            }
            if(startPage<=0){
                startPage=1
            }
            let endPage=0;
            if (startPage+2>pageInfo.pages){
                endPage=pageInfo.pages
            }else {
                endPage=startPage+2;
            }

            for (var k = startPage; k <=endPage; k++) {
                ulPage += `<li><a `;
                if (pageInfo.pageNum == k) {
                    ulPage += ` class="active href="javascript:page(${k})">${k}</a></li>`;
                } else {
                    ulPage += ` href="javascript:page(${k})">${k}</a></li>`;
                }
            }

            if (pageInfo.pageNum >= pageInfo.pages) {
                ulPage += ` <li class="disabled"><a href="javascript:void(0)">»</a></li>`;
            } else {
                ulPage += ` <li><a href="javascript:page(${pageInfo.pageNum + 1})">»</a></li>`;
            }
            ulPage += ` <li ><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>`;
            ulPage += ` </ul>
                    </div>`;

            strjobs += ulPage;
            jobs.innerHTML = strjobs;
        }


    })
}


function searchMinMoney(e){
    let minM=$(e).text().split("-")[0];
    $.get('/dev/post/postminsearchsearch?pageNum=1&money='+minM, function (result) {
        console.log(result)
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left_top");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney=""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples=""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            let pageInfo = result.data.jobPageInfo;
            let startPage = pageInfo.pageNum;
            if (startPage + 2 >= pageInfo.pages) {
                startPage = pageInfo.pages - 2
            }
            let ulPage = `<div style="margin-top: 55px">
                        <ul class="pagination">`;

            if (startPage <= 1) {
                ulPage += `<li class="disabled"><a href="javascript:void(0)">«</a></li>`;
            } else {
                ulPage += `<li><a href="javascript:page(${pageInfo.pageNum - 1})">«</a></li>`
            }
            if(startPage<=0){
                startPage=1
            }
            let endPage=0;
            if (startPage+2>pageInfo.pages){
                endPage=pageInfo.pages
            }else {
                endPage=startPage+2;
            }

            for (var k = startPage; k <=endPage; k++) {
                ulPage += `<li><a `;
                if (pageInfo.pageNum == k) {
                    ulPage += ` class="active href="javascript:page(${k})">${k}</a></li>`;
                } else {
                    ulPage += ` href="javascript:page(${k})">${k}</a></li>`;
                }
            }

            if (pageInfo.pageNum >= pageInfo.pages) {
                ulPage += ` <li class="disabled"><a href="javascript:void(0)">»</a></li>`;
            } else {
                ulPage += ` <li><a href="javascript:page(${pageInfo.pageNum + 1})">»</a></li>`;
            }
            ulPage += ` <li ><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>`;
            ulPage += ` </ul>
                    </div>`;

            strjobs += ulPage;
            jobs.innerHTML = strjobs;
        }


    })
}


function searchJobButton(){
    let name=$('#searchjobbutton').val()
    $.get('/dev/post/postbuttonsearch?pageNum=1&name='+name, function (result) {
        console.log(result)
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left_top");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney=""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples=""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            let pageInfo = result.data.jobPageInfo;
            let startPage = pageInfo.pageNum;
            if (startPage + 2 >= pageInfo.pages) {
                startPage = pageInfo.pages - 2
            }
            let ulPage = `<div style="margin-top: 55px">
                        <ul class="pagination">`;

            if (startPage <= 1) {
                ulPage += `<li class="disabled"><a href="javascript:void(0)">«</a></li>`;
            } else {
                ulPage += `<li><a href="javascript:page(${pageInfo.pageNum - 1})">«</a></li>`
            }
            if(startPage<=0){
                startPage=1
            }
            let endPage=0;
            if (startPage+2>pageInfo.pages){
                endPage=pageInfo.pages
            }else {
                endPage=startPage+2;
            }

            for (var k = startPage; k <=endPage; k++) {
                ulPage += `<li><a `;
                if (pageInfo.pageNum == k) {
                    ulPage += ` class="active href="javascript:page(${k})">${k}</a></li>`;
                } else {
                    ulPage += ` href="javascript:page(${k})">${k}</a></li>`;
                }
            }

            if (pageInfo.pageNum >= pageInfo.pages) {
                ulPage += ` <li class="disabled"><a href="javascript:void(0)">»</a></li>`;
            } else {
                ulPage += ` <li><a href="javascript:page(${pageInfo.pageNum + 1})">»</a></li>`;
            }
            ulPage += ` <li ><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>`;
            ulPage += ` </ul>
                    </div>`;

            strjobs += ulPage;
            jobs.innerHTML = strjobs;
        }

    })
}

